class MyMath:
    def __init__(self,a,b):
        if (type(a)==int or type(a)==float) and (type(b)==int or type(b)==float):
            self.a=a
            self.b=b
        else:
            print('输入数字好吧')
    def add(self):
        return self.a+self.b
    def sub(self):
        return self.a-self.b
    def mul(self):
        return self.a*self.b
    def div(self):
        if self.b==0:
            return '分母不能为0'
        else:
            return self.a/self.b
m_1=MyMath(1,2)
print(m_1.add())
print(m_1.sub())
print(m_1.mul())
print(m_1.div())
print('-----------------1--------------------')


#将事物抽象出类，并创建实例
class Door():
    UsedFor='我可以防盗'
    def __init__(self,special):
        self.special='我的特点是：'+special

glass_door=Door('透光')
print(f'我是玻璃门，{glass_door.UsedFor},{glass_door.special}')
wooden_door=Door('便宜')
print(f'我是木门，{wooden_door.UsedFor},{wooden_door.special}')
iron_gate=Door('耐用')
print(f'我是铁门，{iron_gate.UsedFor},{iron_gate.special}')
print('-----------------2--------------------')


#创建多个继承作业2父类的子类
class Glass_Door(Door):
    name='我是玻璃门--'
class Wooden_Door(Door):
    name='我是木门--'
class Iron_Gate(Door):
    name='我是铁门--'

glass_door=Glass_Door('透光')
print(glass_door.name,glass_door.UsedFor,glass_door.special)
wooden_door=Wooden_Door('便宜')
print(wooden_door.name,wooden_door.UsedFor,wooden_door.special)
iron_gate=Iron_Gate('耐用')
print(iron_gate.name,iron_gate.UsedFor,iron_gate.special)
print('-----------------3--------------------')